package com.briup.estore.common.vo;



import com.fasterxml.jackson.annotation.JsonFormat;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Description: 订单详情展示对象
 * @Author: adam
 * @Date: 2023/7/26 09:55
 */
public class OrderDetailVO {
    /**
     *订单编号
     */
    private String id;
    /**
     *订单状态
     * 1.已创建未支付
     * 2.已支付未发货
     * 3.已发货未收货
     * 4.已收货
     * 5.已关闭 只能关闭 已创建未支付的订单
     */
    private Integer status;
    /**
     *下单用户名
     */
    private String username;
    /**
     *下单时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Timestamp createDate;
    /**
     *支付时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Timestamp payDate;
    /**
     *收件人
     */
    private String receiveUsername;
    /**
     *收货地址
     */
    private String receiveAddress;
    /**
     *收货人联系方式
     */
    private String receivePhone;
    /**
     *订单总额
     */
    private BigDecimal totalPrice;
    /**
     *订单商品数
     */
    private Integer num;
    /**
     *支付方式
     */
    private String payWay;
    /**
     *快递单号
     */
    private String trackingNumber;
    /**
     *配送方式
     */
    private String distributionMode;
    /**
     *图书信息
     */
    private List<OrderBookVO> orderItems;
    /**
     *订单商品数
     */
    private Integer totalNum;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Timestamp getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Timestamp createDate) {
        this.createDate = createDate;
    }

    public Timestamp getPayDate() {
        return payDate;
    }

    public void setPayDate(Timestamp payDate) {
        this.payDate = payDate;
    }

    public String getReceiveUsername() {
        return receiveUsername;
    }

    public void setReceiveUsername(String receiveUsername) {
        this.receiveUsername = receiveUsername;
    }

    public String getReceiveAddress() {
        return receiveAddress;
    }

    public void setReceiveAddress(String receiveAddress) {
        this.receiveAddress = receiveAddress;
    }

    public String getReceivePhone() {
        return receivePhone;
    }

    public void setReceivePhone(String receivePhone) {
        this.receivePhone = receivePhone;
    }

    public BigDecimal getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public String getPayWay() {
        return payWay;
    }

    public void setPayWay(String payWay) {
        this.payWay = payWay;
    }

    public String getTrackingNumber() {
        return trackingNumber;
    }

    public void setTrackingNumber(String trackingNumber) {
        this.trackingNumber = trackingNumber;
    }

    public String getDistributionMode() {
        return distributionMode;
    }

    public void setDistributionMode(String distributionMode) {
        this.distributionMode = distributionMode;
    }

    public List<OrderBookVO> getOrderItems() {
        return orderItems;
    }

    public void setOrderItems(List<OrderBookVO> orderItems) {
        this.orderItems = orderItems;
    }

    public Integer getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(Integer totalNum) {
        this.totalNum = totalNum;
    }
    public void  genPrice(){
        for (OrderBookVO item : orderItems) {
            item.setTotalPrice(BigDecimal.valueOf(item.getNum()).multiply(BigDecimal.valueOf(item.getPrice())));
            totalPrice=totalPrice.add(item.getTotalPrice());
            totalNum+=item.getNum();
        }
    }

}
